package sculove.spring.zzz.comCd.controller;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import sculove.spring.framework.common.AbstractController;
import sculove.spring.zzz.comCd.model.ComCdDTO;
import sculove.spring.zzz.comCd.service.ComCdManager;
import sculove.spring.zzz.comCd.service.ComCdService;

@Controller
public class ComCdController extends AbstractController {

    @Resource(name="zzz.comCdService")
    private ComCdService comCdService;

    public ComCdService getComCdService(){
        return comCdService;
    }
    
    public void setComCdService(ComCdService comCdService){
        this.comCdService = comCdService;
    }

    @RequestMapping(value = "/zzz.inqComCdLst.htm")
    public ModelAndView inqComCdLst() throws Exception{
        HashMap <String, List<ComCdDTO>> map = new HashMap<String, List<ComCdDTO>>();
        map.put("ComCdLst", comCdService.inqComCdLst());
        return new ModelAndView("jsonview", map);
    } 

    @RequestMapping(value = "/zzz.inqComCdLstPaging.htm")
    public ModelAndView inqComCdLstPaging() throws Exception{
        HashMap <String, List<ComCdDTO>> map = new HashMap<String, List<ComCdDTO>>();
//        map.put("ComCdLst", comCdService.inqComCdLstPaging());
        return new ModelAndView("jsonview", map);        
    }

    @RequestMapping(value = "/zzz.inqComCd.htm")
    public ModelAndView inqComCd(@RequestParam("comCd") List<String> list) throws Exception{
        HashMap<String, ComCdDTO> lstMap = new HashMap<String, ComCdDTO>();

        for(int i = 0; i < list.size(); i++){
            String key = list.get(i);
            lstMap.put(key, ComCdManager.getComCdDTO(key));
        }
        return new ModelAndView("jsonview", comCdService.inqComCd(lstMap));    
    }
}
